<template>
	<view class="content">
		<!-- <live-pusher id="livePusher" ref="livePusher" class="livePusher" url="" mode="SD" :muted="true" :enable-camera="true"
		 :auto-focus="true" :beauty="1" whiteness="2" aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error="error"></live-pusher>
		<button class="btn" @click="start">开始推流</button>
		<button class="btn" @click="pause">暂停推流</button>
		<button class="btn" @click="resume">resume</button>
		<button class="btn" @click="stop">停止推流</button>
		<button class="btn" @click="snapshot">快照</button>
		<button class="btn" @click="startPreview">开启摄像头预览</button>
		<button class="btn" @click="stopPreview">关闭摄像头预览</button>
		<button class="btn" @click="switchCamera">切换摄像头</button>
		<button class="btn" @click="bofang">去播放</button> -->
		<!-- <view>
				<video src="rtmp://192.168.1.178:1935/live/exp" style="width: 100vw;height: 400rpx;" :autoplay="true" controls></video>
		</view> -->
		<view class="black">
			<view class="live-item" v-for="(item,index) in arr" :key="index">
				<view class="" @click="go(item.site_id)">
					{{item.key}}
				</view>
			</view>
		</view>

		<view class="footer">
			<view class="footer-item">
				直播列表
			</view>
			<view class="footer-item active" @click="live()">
				开始直播
			</view>
		</view>
		<view class="">
			<yyqLivePusher @close="handleClose" :livepushurl="url"  v-if="flag"></yyqLivePusher>
		</view>
		<!-- <loading-cover ref="loadingCover"></loading-cover> -->
	</view>
</template>

<script>
	import yyqLivePusher from '@/components/yyq-LivePusher/yyq-LivePusher.vue' //
	export default {
		data() {
			return {
				// url:'rtmp://qixinlive.shenguanyun.show/qixinlive/0000?auth_key=1608199146-0-0-c241d72568d3ca4f3804dce9f31372a4',
				url: 'rtmp://125834.livepush.myqcloud.com/live/qixinlive?txSecret=6bc1a449f7000a0487e784d3acce902e&txTime=5FF561C7',
				flag: false,
				arr: [{
						site_id: 1,
						key: '第一个店铺',
					},
					// {
					// 	site_id: 2,
					// 	key: '第二个店铺',
					// }, {
					// 	site_id: 3,
					// 	key: '第三个店铺',

					// }
				]
			}
		},
		components: {
			yyqLivePusher
		},
		onReady() {},
		onShow() {

		},
		methods: {
			handleClose({
				confirm,
				cancel
			}) {
				if (confirm) {
					console.log('成功关闭')
					this.flag = false
				} else if (cancel) {
					console.log('取消关闭')
				}
			},
			live() {
				console.log('点击直播');
				this.flag = true
			},
			// redirectTo(link){
			// 	console.log(link);
			// 	this.$util.redirectTo(link)
			// },
			go(site_id) {
				this.$util.redirectTo('/otherpages/member/live/index/index', {
					site_id: site_id
				});
			}
		},
		// data() {
		// 	return {
		// 		context: '',
		// 		fil: true,
		// 		pusherUrl: 'rtmp://livepush.huahualive.net/live/dddd', //推流地址,支持RTMP协议。    
		// 		beauty: 0, //美颜,取值范围 0-9（iOS取值范围为1）,0 表示关闭    
		// 		whiteness: 0, //美白,取值范围 0-9（iOS取值范围为1),0 表示关闭    
		// 		quality: 'HD', //推流视频模式,可取值:SD(标清),HD（高清）, FHD（超清）    
		// 		muted: true, //是否静音    
		// 		height: '100px', //高度    
		// enableCamera: true, //开启摄像头    
		// autoFocus: true, //自动聚集    
		// }
		// },
		// onReady() {
		// 	// // 注意：需要在onReady中 或 onLoad 延时
		// 	setTimeout(function() {
		// 		this.context = uni.createLivePusherContext("livePusher", this);
		// 		console.log(this.context)
		// 	}, 500);
		// setTimeout(function(){
		// 	this.context = plus.video.LivePusher('livePusher', this)
		// },500)
		// this.context = uni.createLivePusherContext("livePusher", this);
		// console.log(this.$refs.livePusher.attr)
		// this.height = uni.getSystemInfoSync().windowHeight + 'px';
		// if (uni.getSystemInfoSync().platform == "android") {
		// 	this.beauty = 1;
		// 	this.whiteness = 2;
		// }
		// if (uni.getSystemInfoSync().platform == "ios") {
		// 	this.beauty = 0.1;
		// 	this.whiteness = 0.2;
		// }
		// },
		// methods: {
		// 		bofang() {
		// 			console.log('播放')
		// 		},
		// 		//状态变化事件    
		// 		statechange(e) {
		// 			console.log("statechange:" + JSON.stringify(e));
		// 		},
		// 		//网络状态通知事件   	
		// 		netstatus(e) {
		// 			console.log("netstatus:" + JSON.stringify(e));
		// 		},
		// 		//渲染错误事件  
		// 		error(e) {
		// 			console.log("error:" + JSON.stringify(e));
		// 		},
		// 		start: function() {
		// 			console.log(this.content)
		// 			this.context.start({
		// 				success: (a) => {
		// 					console.log("livePusher.start:" + JSON.stringify(a));
		// 				}
		// 			});
		// 		},
		// 		close: function() {
		// 			this.context.close({
		// 				success: (a) => {
		// 					console.log("livePusher.close:" + JSON.stringify(a));
		// 				}
		// 			});

		// 		},
		// 		snapshot: function() {
		// 			this.context.snapshot({
		// 				success: (e) => {
		// 					console.log(JSON.stringify(e));
		// 				}
		// 			});
		// 		},
		// 		resume: function() {
		// 			this.context.resume({
		// 				success: (a) => {
		// 					console.log("livePusher.resume:" + JSON.stringify(a));
		// 				}
		// 			});
		// 		},
		// 		pause: function() {
		// 			this.context.pause({
		// 				success: (a) => {
		// 					console.log("livePusher.pause:" + JSON.stringify(a));
		// 				}
		// 			});
		// 		},
		// 		stop: function() {
		// 			this.context.stop({
		// 				success: (a) => {
		// 					console.log(JSON.stringify(a));
		// 				}
		// 			});
		// 		},
		// 		switchCamera: function() {
		// 			this.context.switchCamera({
		// 				success: (a) => {
		// 					console.log("livePusher.switchCamera:" + JSON.stringify(a));
		// 				}
		// 			});
		// 		},
		// 		startPreview: function() {
		// 			this.context.startPreview({
		// 				success: (a) => {
		// 					console.log("livePusher.startPreview:" + JSON.stringify(a));
		// 				}
		// 			});
		// 		},
		// 		stopPreview: function() {
		// 			this.context.stopPreview({
		// 				success: (a) => {
		// 					console.log("livePusher.stopPreview:" + JSON.stringify(a));
		// 				}
		// 			});
		// 		}
		// 	}
	}
</script>


<style lang="scss" scoped>
	.content {
		background: #000;
		overflow: hidden;
		width: 750upx;
		position: fixed;

		.black {
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			justify-content: center;
			background-color: #FFFFFF;

			.live-item {
				padding: 20px;
				border-bottom: 5px solid #f7f7f7;
			}
		}
	}

	.footer {
		position: fixed;
		bottom: 0;
		background-color: white;
		border-top: 2rpx solid #D4D4D4;
		width: 100%;
		display: flex;
		height: 100rpx;

		.footer-item {
			font-size: 30rpx;
			line-height: 100rpx;
			flex: 1;
			text-align: center;
			color: #909399;
		}

		.active {
			color: #FF315B;
		}
	}
</style>
